﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GsnHelper;

namespace ZhongheCms.Models
{
    public partial class GswTblMsg
    {
        public static List<GswTblMsg> GetMsgList(string sdate, string edate, string title, string funcId, int cusid)
        {
            //ContentType
            sdate = string.IsNullOrWhiteSpace(sdate) ? "" : Convert.ToDateTime(sdate).ToShortDateString();
            edate = string.IsNullOrWhiteSpace(edate) ? "" : Convert.ToDateTime(edate).ToShortDateString();
            var strSql = "select * from GswTblMsg where FunctionId='" + funcId + "' and CustomerId=" + cusid;
            //if (!string.IsNullOrWhiteSpace(ower))
            //{
            //    strSql += " and Author = '" + ower + "' ";
            //}
            if (!string.IsNullOrWhiteSpace(title))
            {
                strSql += " and  Title like '%" + title + "%' ";
            }
            if (InputValid.IsDate(sdate))
            {
                strSql += " and MsgDate>='" + sdate + "'";
            }
            if (InputValid.IsDate(edate))
            {
                strSql += " and MsgDate<='" + edate + "'";
            }
            strSql += " order by MsgDate desc";

            return Fetch(strSql);
        }

    }
}